layui.use(['form', 'jquery', 'layer'], function() {
	var form = layui.form,
		$ = layui.$,
		table = layui.table,
		layer = layui.layer;
	form.on('checkbox(select_category)', function(e) {
		var get_checked = e.elem.checked,
			obj = $(this),
			p_div = obj.parent('div'),
			class_name = p_div.attr('class');
		switch(class_name) {
			case 'layui-input-block block-one':
				p_div.nextAll('div').find('input[type="checkbox"]').prop('checked', get_checked);
				form.render('checkbox');
				break;
			case 'layui-input-block block-two':
				p_div.next('div').find('input[type="checkbox"]').prop('checked', get_checked);
				if(get_checked == true) {
					p_div.parent('div').prevAll('div.block-one').find('input[type="checkbox"]').prop('checked', true);
				}
				form.render('checkbox');
				break;
			case 'layui-input-inline':
				p_div.parent('div.block-three').parent('div.layui-form-item').prev('div.block-two').find('input[type="checkbox"]').prop('checked', true);
				p_div.parent('div.block-three').parent('div.layui-form-item').prev('div.block-two').parent('div').prevAll('div.block-one').find('input[type="checkbox"]').prop('checked', true);
				form.render('checkbox');
				break;
			default:
				break;
		}
	});
	form.on('switch(copy_product)', function(data) {
		var get_checked = data.elem.checked,
			p_div = $(this).parent('div');
		if(get_checked == true) {
			p_div.next('div.layui-word-aux').show();
		} else {
			p_div.next('div.layui-word-aux').hide();
		}
	})
	form.on('submit(submit_copy)', function(data) {
		var field = data.field,
			url = data.form.action,
			load_ing = layer.load(1);
		send_info(url, field, function(data) {
			layer.close(load_ing);
			if(data.code == 0) {
				layer.msg(data.data, {
					icon: 2,
					anim: 6
				});
				return false;
			} else {
				layer.msg(data.data, {
					icon: 1,
					anim: 6
				});
				parent.layui.table.reload('category_list');
			}
		})
	})
})